import Vue from 'vue'
// 导入路由
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// 导入组件
import login from '@/views/user/login.vue'
import index from '@/views/home/index.vue'
import mainCount from '@/views/home/mainCount.vue'
import articleList from '@/views/article/articleList.vue'
import articleRelease from '@/views/article/articleRelease.vue'
import articleCategory from '@/views/article/articleCategory.vue'
import comment from '@/views/comment/comment.vue'
import user from '@/views/user/user.vue'
// 配置路由规则
const routes = [
  {
    name: 'login',
    path: '/login',
    component: login
  },
  {
    name: 'index',
    path: '/index',
    component: index,
    children:[
      {
        name: 'mainCount',
        path: '/mainCount',
        component: mainCount
      },
      {
        name: 'articleList',
        path: '/articleList',
        component: articleList
      },
      {
        name: 'articleRelease',
        path: '/articleRelease',
        component: articleRelease
      },
      {
        name: 'articleCategory',
        path: '/articleCategory',
        component: articleCategory
      },
      {
        name: 'comment',
        path: '/comment',
        component: comment
      },
      {
        name: 'user',
        path: '/user',
        component: user
      },
      {        
        path: '/',
        redirect: '/mainCount'
      },
    ]
  },
  {
    path: '/',
    redirect:'/index'
  },
]
// const originPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location,resole,reject){
//   if(resole || reject){
//     return originPush.call(this,location,resole,reject)
//   }else {
//     return originPush.call(this,location).catch((err)=>{
//     })
//   }
// }
// 挂载路由
const router = new VueRouter({
  routes
})

export default router
